#ifndef __Map_h_
#define __Map_h_

#include <Terrain/OgreTerrain.h>
#include <Terrain/OgreTerrainGroup.h>
#include <OgreRoot.h>
#include <Ogre/OgreManualObject.h>
#include "EasyBMP.h"
#include <cmath>

class Map
{

public:
	Map(Ogre::SceneManager* mSceneMgr, Ogre::String sHeightMapFileName);
	~Map(void);

	Ogre::TerrainGlobalOptions* mTerrainGlobals;
    Ogre::TerrainGroup* mTerrainGroup;

	Ogre::String getHeightMapName(void);
	Ogre::Real getWorldSize(void);
	Ogre::Vector3 getWorldPoz(void);

	void rebuildTerrain(Ogre::String sHeightMapFileName);
    void defineTerrain(Ogre::String sHeightMapFileName);
	void changeTexture(int layerIndex, int size, Ogre::StringVector *textures);
	Ogre::Terrain* getTerrain(void);
	Ogre::TerrainGlobalOptions* getTerrainGlobalOptions(void);
	Ogre::TerrainGroup* getTerrainGroup(void);

	void initBlendMaps(void);
	void initBlendMaps(Ogre::Real minHeight0, Ogre::Real fadeDist0, Ogre::Real minHeight1, Ogre::Real fadeDist1);
    void configureTerrainDefaults(void);
	void configureTerrainDefaults(Ogre::String layer1Diffuse, Ogre::String layer1Normal, Ogre::String layer2Diffuse, Ogre::String layer2Normal, Ogre::String layer3Diffuse, Ogre::String layer3Normal);
	bool editTerrain(const Ogre::Vector3& mCentrepos, Ogre::Real nTimeElapsed, Ogre::Real nBrushSizeTerrainSpace, bool bRaise);

	void generateHeightMap(Ogre::String fileName);

private:
	Ogre::String heightMapName;
	Ogre::Vector3 mWorldPoz;
	Ogre::Real nWorldSize;
	Ogre::SceneManager* mSceneMgr;
	void getTerrainImage(Ogre::String sImgFileName, bool bFlipX, bool bFlipY, Ogre::Image& mImg);
};

#endif // #ifndef __Map_h_
